<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link th:href="@{/animate.min.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/common.js}"></script>


    <style>

        a, button {
            cursor: pointer;
        }


    </style>

</head>
<body style="background-color: #F8F8F8;overflow-x: hidden">
<div>

    <!--    顶部导航-->
    <div class="layui-header" style="background-color: black;">
        <ul class="layui-nav layui-layout-left" style="background-color: black">
            <li class="layui-nav-item">后台管理系统</li>
        </ul>
        <ul class="layui-nav layui-layout-right" style="background-color: black">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <span><text th:text="${param.loginName}"></text></span>
                </a>
            </li>
            <li class="layui-nav-item"><a th:href="@{/adminController/logout}">退出</a></li>
        </ul>
    </div>

    <!--    内容-->
    <div style="display: flex;position: relative;top: 30px">

        <!--    左侧菜单-->
        <div style="width: 23%;height: 200px">
            <div class="layui-panel" style="position:relative;left: 60px;width: 75%;box-shadow:0 0 10px
            #E0E0E0;border-radius: 10px">
                <ul class="layui-menu" id="docDemoMenu1">
                    <li lay-options="{id: 1}" id="init">
                        <div class="layui-menu-body-title" style="text-align: center;font-size: 16px">
                            审核用户
                        </div>
                    </li>
                    <li lay-options="{id: 2}">
                        <div class="layui-menu-body-title" style="text-align: center;font-size: 16px">
                            管理用户
                        </div>
                    </li>
                    <li lay-options="{id: 3}">
                        <div class="layui-menu-body-title" style="text-align: center;font-size: 16px">
                            管理话题
                        </div>
                    </li>
                    <li lay-options="{id: 4}" id="init4">
                        <div class="layui-menu-body-title" style="text-align: center;font-size: 16px">
                            管理模块
                        </div>
                    </li>
                    <li lay-options="{id: 5}" id="init5">
                        <div class="layui-menu-body-title" style="text-align: center;font-size: 16px">
                            修改密码
                        </div>
                    </li>

                </ul>
            </div>

        </div>

        <!--        右侧内容-->
        <div style="width: 77%">
            <div class="animated fadeIn" style="width: 90%;height: 540px;background-color: #fff;border: solid
                #E0E0E0 1px;border-radius: 10px;box-shadow:0 0 10px #E0E0E0;position: relative;left: 30px">
                <!--                标题栏-->
                <div style="height: 8%">
                    <div style="position: relative;top: 50%;left: 2%">
                        <span id="titleSpan" style="font-size: 15px"></span>
                    </div>
                </div>

                <div class="line" style="position: relative;left: 18px"></div>

                <!--     内容-->
                <div id="appendArea" style="height: 75%;position: relative;top: 2%">
                    <!--<div class="animated fadeIn" style="padding: 10px 0 0 40px;width: 40%;display: flex">
                        <input id="query" style="width: 80%;height: 25px;padding-left: 8px" type="text"
                               placeholder="查询用户名/姓名">
                        <button onclick="initPage()"
                                style="width: 10%;margin-left: 10px;font-size: 13px;border: none;background-color:
                        #000000;color: white;"
                                type="button">查询
                        </button>
                    </div>-->


                </div>
                <div style="padding: 20px;" id="page"></div>

            </div>
        </div>

    </div>
</div>


</div>


</div>


<script th:src="@{/layui/jquery-1.11.2.js}"></script>
<script th:src="@{/layui/layui.js}" charset="utf-8"></script>
<script>
    var dropdown;
    var laypage;
    $(function () {
        layui.use(['element', 'form', 'table', 'layer', 'dropdown', 'laypage'], function () {
            var element = layui.element;
            var form = layui.form;
            var table = layui.table;
            var layer = layui.layer;
            dropdown = layui.dropdown;
            laypage = layui.laypage;
            init();
            if (getQueryVariable('initNum') == '') {
                $("#init").trigger("click");
            } else {
                $("#init" + getQueryVariable("initNum")).trigger("click");
            }

        });
    });

    function init() {
        dropdown.on('click(docDemoMenu1)', function (options) {
            $("#titleSpan").empty();
            if (options.id == '1') {          //菜单列表的 lay-options 中的参数为1  加载待审核用户
                $("#titleSpan").append("申请信息");
                $("#page").css('display', "flex");
                initPage(loadUnverifiedUser, 'UnverifiedUser');
            } else if (options.id == '2') {
                $("#titleSpan").append("用户信息");
                $("#page").css('display', "flex");
                initPage(loadUserList, 'userList');
            } else if (options.id == '3') {
                $("#titleSpan").append("话题信息");
                $("#page").css('display', "flex");
                initPage(loadTopicList, 'topicList');
            } else if (options.id == '4') {
                $("#titleSpan").append("板块信息");
                $("#page").css('display', "flex");
                initPage(loadTagList, 'tagList');
            } else if (options.id == '5') {
                $("#titleSpan").append("修改密码");
                $("#page").css('display', "none");  //屏蔽分页栏
                loadModifyPwdPage();
            }
        });
    }

    function initPage(func, type) {
        let count = countFunc(type);
        let limit = 6;  //默认一页展示条数
        if (type == 'topicList') {
            limit = 4;  //话题信息占位置多
        }
        laypage.render({
            elem: 'page',
            count: count, //数据总数
            limit: limit,
            jump: function (obj, first) {
                func(obj.curr, obj.limit);//当前页 //每页显示的条数
            }
        });
    }

    //通用 数据总数
    function countFunc(type) {
        let query = $("#query").val();
        if (query == undefined) {
            query = '';
        }
        let count = 0;
        $.ajax({
            url: '/adminController/count',
            data: {query: query, type: type},
            async: false,
            type: 'get',
            contentType: 'application/json',
            success: function (resp) {
                count = resp.data;
            }
        });
        return count;
    }

    // 1.用户注册申请信息
    function loadUnverifiedUser(curr, limit) {
        let appendArea = $("#appendArea");
        appendArea.empty();
        appendArea.append("<div class='animated fadeIn' style=\"width: 90%;padding-left:40px;padding-top: 15px \">\n" +
            "                        <table class=\"layui-table\" lay-skin=\"line\">\n" +
            "                            <colgroup>\n" +
            "                                <col width=\"120\">\n" +
            "                                <col width=\"120\">\n" +
            "                                <col width=\"160\">\n" +
            "                                <col width=\"280\">\n" +
            "                                <col width=\"220\">\n" +
            "                                <col width=\"130\">\n" +
            "                            </colgroup>\n" +
            "                            <thead>\n" +
            "                            <tr>\n" +
            "                                <th>登录名</th>\n" +
            "                                <th>姓名</th>\n" +
            "                                <th>电话</th>\n" +
            "                                <th>住址</th>\n" +
            "                                <th>申请时间</th>\n" +
            "                                <th>操作</th>\n" +
            "                            </tr>\n" +
            "                            </thead>\n" +
            "                            <tbody id=\"tbody1\">\n" +
            "\n" +
            "                            </tbody>\n" +
            "                        </table>\n" +
            "                    </div>");
        $.ajax({
            url: '/adminController/loadUnverifiedUser',
            data: {curr: curr, limit: limit},
            async: false,
            type: 'get',
            contentType: 'application/json',
            success: function (resp) {
                if (resp.code == 0) {
                    $("#tbody1").empty();
                    $.each(resp.data, function (index, item) {
                        $("#tbody1").append("<tr id='tr" + item.id + "'>" +
                            "<td>" + item.loginName + "</td>" +
                            "<td>" + item.name + "</td>" +
                            "<td>" + item.tel + "</td>" +
                            "<td>" + item.address + "</td>" +
                            "<td>" + item.createTime + "</td>" +
                            "<td><div title='" + item.loginName + "' id='" + item.id + "' style='display: flex'>" +
                            "<a onclick='verifyUser(this,\"pass\")' style='font-size: 13px'>通过</a>" +
                            "<a onclick='verifyUser(this,\"notPass\")' style='font-size: 13px;position: relative;left: 10px;color:red'>不通过</a>" +
                            "</td></div>" +
                            "</tr>")
                    })
                } else {
                    layer.msg(resp.msg);
                }
            }
        });
    }

    //1.审核用户操作
    function verifyUser(e, opera) {
        let loginName = $(e).parent().attr('title');
        let id = $(e).parent().attr('id');
        let state;
        let confirmMsg;
        if (opera == 'pass') {
            confirmMsg = '确认通过审核？';
            state = '1';
        } else if (opera == 'notPass') {
            confirmMsg = '确认驳回注册申请？';
            state = '-1';
        }
        layer.confirm(confirmMsg, {
            btn: ['确认', '取消'],
            yes: function () {
                $.get('/adminController/verifyUser', {loginName: loginName, state: state}, function (resp) {
                    layer.msg(resp.msg);
                    if (resp.code == 0) {
                        $("#tr" + id).empty();
                    }
                });
            }
        })
    }

    //2.当前系统中用户信息
    function loadUserList(curr, limit) {
        let query = $("#query").val();  //获得当前查询条件
        let appendArea = $("#appendArea");
        appendArea.empty();
        //搜索栏
        appendArea.append("<div class=\"animated fadeIn\" style=\"padding: 10px 0 0 40px;width: 40%;display: flex\">\n" +
            "                        <input id=\"query\" style=\"width: 80%;height: 25px;padding-left: 8px;border-radius: 7px\" type=\"text\"\n" +
            "                               placeholder=\"查询登录名/姓名\">\n" +
            "                        <button onclick=\"initPage(loadUserList, 'userList')\"\n" +
            "                                style=\"width: 10%;border-radius: 7px;margin-left: 10px;font-size: 13px;border: none;background-color:\n" +
            "                        #000000;color: white;\"\n" +
            "                                type=\"button\">查询\n" +
            "                        </button>\n" +
            "                    </div>");
        $("#query").val(query);  //反写
        //表头
        appendArea.append("<div class='animated fadeIn' style=\"width: 90%;padding-left:40px;padding-top: 15px \">\n" +
            "                        <table class=\"layui-table\" lay-skin=\"line\">\n" +
            "                            <colgroup>\n" +
            "                                <col width=\"120\">\n" +
            "                                <col width=\"120\">\n" +
            "                                <col width=\"160\">\n" +
            "                                <col width=\"240\">\n" +
            "                                <col width=\"100\">\n" +
            "                                <col width=\"220\">\n" +
            "                                <col width=\"130\">\n" +
            "                            </colgroup>\n" +
            "                            <thead>\n" +
            "                            <tr>\n" +
            "                                <th>登录名</th>\n" +
            "                                <th>姓名</th>\n" +
            "                                <th>电话</th>\n" +
            "                                <th>住址</th>\n" +
            "                                <th>状态</th>\n" +
            "                                <th>申请时间</th>\n" +
            "                                <th>操作</th>\n" +
            "                            </tr>\n" +
            "                            </thead>\n" +
            "                            <tbody id=\"tbody1\">\n" +
            "\n" +
            "                            </tbody>\n" +
            "                        </table>\n" +
            "                    </div>");
        $.ajax({
            url: '/adminController/loadUserList',
            data: {curr: curr, limit: limit, query: query},
            async: false,
            type: 'get',
            contentType: 'application/json',
            success: function (resp) {
                if (resp.code == 0) {
                    $("#tbody1").empty();
                    $.each(resp.data, function (index, item) {
                        let stateBtn = item.state == '2' ? '解封' : '封禁';
                        let state = item.state == '2' ? '封禁中' : '正常';
                        $("#tbody1").append("<tr id='tr" + item.id + "'>" +
                            "<td>" + item.loginName + "</td>" +
                            "<td>" + item.name + "</td>" +
                            "<td>" + item.tel + "</td>" +
                            "<td>" + item.address + "</td>" +
                            "<td id='td" + item.id + "'>" + state + "</td>" +
                            "<td>" + item.createTime + "</td>" +
                            "<td><div title='" + item.loginName + "' id='" + item.id + "' style='display: flex'>" +
                            "<a onclick='manageUser(this,\"ban\")' style='font-size: 13px'>" + stateBtn + "</a>" +
                            "<a onclick='manageUser(this,\"delete\")' style='font-size: 13px;position: relative;left: 10px;color:red'>移除</a>" +
                            "</td></div>" +
                            "</tr>")
                    })
                } else {
                    layer.msg(resp.msg);
                }
            }
        });
    }

    //2.管理用户操作
    function manageUser(e, opera) {
        let banType = e.text;  //获得操作名以判断是解封还是封禁用户
        let loginName = $(e).parent().attr('title');
        let id = $(e).parent().attr('id');
        let state;
        let delFlag;
        let confirmMsg;
        if (opera == 'ban') {
            if (banType == '封禁') {
                confirmMsg = '确认封禁该用户？';
                state = '2';
            } else if (banType == '解封') {
                confirmMsg = '确认解封该用户？';
                state = '1';
            }

        } else if (opera == 'delete') {
            confirmMsg = '确认移除该用户？';
            delFlag = '1';
        }
        layer.confirm(confirmMsg, {
            btn: ['确认', '取消'],
            yes: function () {
                $.get('/adminController/manageUser', {loginName: loginName, state: state, delFlag: delFlag}, function
                    (resp) {
                    layer.msg(resp.msg);
                    if (opera == 'delete' && resp.code == 0) {
                        $("#td" + id).empty();
                    } else if (opera == 'ban' && resp.code == 0) {
                        let tdState = $("#td" + id);
                        if (tdState.text() == '正常') {
                            tdState.empty();
                            $("#td" + id).text('封禁中');
                            $(e).text('解封')
                        } else {
                            tdState.empty();
                            $("#td" + id).text('正常');
                            $(e).text('封禁');

                        }
                    }
                });
            }
        })
    }

    //3.当前系统中话题信息
    function loadTopicList(curr, limit) {
        let query = $("#query").val();  //获得当前查询条件
        let appendArea = $("#appendArea");
        appendArea.empty();
        //搜索栏
        appendArea.append("<div class=\"animated fadeIn\" style=\"padding: 10px 0 0 40px;width: 40%;display: flex\">\n" +
            "                        <input id=\"query\" style=\"width: 80%;height: 25px;padding-left: 8px;border-radius: 7px\" type=\"text\"\n" +
            "                               placeholder=\"查询关键字\">\n" +
            "                        <button onclick=\"initPage(loadTopicList, 'topicList')\"\n" +
            "                                style=\"width: 10%;border-radius: 7px;margin-left: 10px;font-size: 13px;border: none;background-color:\n" +
            "                        #000000;color: white;\"\n" +
            "                                type=\"button\">查询\n" +
            "                        </button>\n" +
            "                    </div>");
        $("#query").val(query);  //反写
        //表头
        appendArea.append("<div class='animated fadeIn' style=\"width: 90%;padding-left:40px;padding-top: 15px \">\n" +
            "                        <table class=\"layui-table\" lay-skin=\"line\">\n" +
            "                            <colgroup>\n" +
            "                                <col width=\"270\">\n" +
            "                                <col width=\"90\">\n" +
            "                                <col width=\"200\">\n" +
            "                                <col width=\"80\">\n" +
            "                                <col width=\"90\">\n" +
            "                                <col width=\"100\">\n" +
            "                                <col width=\"140\">\n" +
            "                            </colgroup>\n" +
            "                            <thead>\n" +
            "                            <tr>\n" +
            "                                <th>标题</th>\n" +
            "                                <th>发布人</th>\n" +
            "                                <th>发布时间</th>\n" +
            "                                <th>分区</th>\n" +
            "                                <th>留言数</th>\n" +
            "                                <th>状态</th>\n" +
            "                                <th>操作</th>\n" +
            "                            </tr>\n" +
            "                            </thead>\n" +
            "                            <tbody id=\"tbody1\">\n" +
            "\n" +
            "                            </tbody>\n" +
            "                        </table>\n" +
            "                    </div>");
        $.ajax({
            url: '/adminController/loadTopicList',
            data: {curr: curr, limit: limit, query: query},
            async: false,
            type: 'get',
            contentType: 'application/json',
            success: function (resp) {
                if (resp.code == 0) {
                    $("#tbody1").empty();
                    $.each(resp.data, function (index, item) {
                        let state = item.state == '0' ? '待解决' : "已解决";
                        $("#tbody1").append("<tr id='tr" + item.id + "'>" +
                            "<td>" + item.title + "</td>" +
                            "<td>" + item.creatorLoginName + "</td>" +
                            "<td>" + item.createTime + "</td>" +
                            "<td>" + item.tagName + "</td>" +
                            "<td>" + item.commentCount + "</td>" +
                            "<td>" + state + "</td>" +
                            "<td><div id='" + item.id + "' style='display: flex'>" +
                            "<a onclick='manageTopic(this,\"detail\")' style='font-size: 13px'>详情</a>" +
                            "<a onclick='manageTopic(this,\"modify\")' style='font-size: 13px;position: relative;left: 10px'>修改</a>" +
                            "<a onclick='manageTopic(this,\"delete\")' style='font-size: 13px;position: relative;left: 20px;color:red'>删除</a>" +
                            "</td></div>" +
                            "</tr>")
                    })
                } else {
                    layer.msg(resp.msg);
                }
            }
        });
    }

    //3.管理话题操作
    function manageTopic(e, opera) {
        let id = $(e).parent().attr('id');
        if (opera == 'detail') {
            window.location.href = '/user/topicDetail?loginName=' + getQueryVariable("loginName") + '&id=' + id;
        } else if (opera == 'modify') {
            window.location.href = '/user/addTopic?type=modify&id=' + id + '&loginName=' + getQueryVariable('loginName');
        } else if (opera == 'delete') {
            layer.confirm('确认删除该话题？', {
                btn: ['确认', '取消'],
                yes: function () {
                    $.get('/topicController/deleteTopic', {id: id}, function (resp) {
                        layer.msg(resp.msg);
                        if (opera == 'delete' && resp.code == 0) {
                            $("#tr" + id).empty();
                        }
                    });
                }
            })
        }

    }

    //4.板块信息
    function loadTagList(curr, limit) {
        let appendArea = $("#appendArea");
        appendArea.empty();
        //新增栏
        appendArea.append("<div class=\"animated fadeIn\" style=\"padding: 10px 0 0 40px;width: 40%;display: flex\">\n" +
            "                        <input id=\"addTag\" style=\"width: 80%;height: 25px;padding-left: 8px;border-radius: 7px\" type=\"text\"\n" +
            "                               placeholder=\"输入新板块名\">\n" +
            "                        <button onclick=\"manageTag(this,'new')\"\n" +
            "                                style=\"width: 10%;border-radius: 7px;margin-left: 10px;font-size: 13px;border: none;background-color:\n" +
            "                        #000000;color: white;\"\n" +
            "                                type=\"button\">新增\n" +
            "                        </button>\n" +
            "                    </div>");
        //表头
        appendArea.append("<div class='animated fadeIn' style=\"width: 90%;padding-left:40px;padding-top: 15px \">\n" +
            "                        <table class=\"layui-table\" lay-skin=\"line\">\n" +
            "                            <colgroup>\n" +
            "                                <col width=\"150\">\n" +
            "                                <col width=\"200\">\n" +
            "                                <col width=\"250\">\n" +
            "                                <col width=\"100\">\n" +
            "                                <col width=\"120\">\n" +
            "                                <col width=\"80\">\n" +
            "                            </colgroup>\n" +
            "                            <thead>\n" +
            "                            <tr>\n" +
            "                                <th>板块名</th>\n" +
            "                                <th>创建人</th>\n" +
            "                                <th>创建时间</th>\n" +
            "                                <th>话题数</th>\n" +
            "                                <th>状态</th>\n" +
            "                                <th>操作</th>\n" +
            "                            </tr>\n" +
            "                            </thead>\n" +
            "                            <tbody id=\"tbody1\">\n" +
            "\n" +
            "                            </tbody>\n" +
            "                        </table>\n" +
            "                    </div>");
        $.ajax({
            url: '/adminController/loadTagList',
            data: {curr: curr, limit: limit},
            async: false,
            type: 'get',
            contentType: 'application/json',
            success: function (resp) {
                if (resp.code == 0) {
                    $("#tbody1").empty();
                    $.each(resp.data, function (index, item) {
                        let stateBtn = item.delFlag == '0' ? '移除' : '应用';
                        let state = item.delFlag == '0' ? '生效' : '未生效';
                        $("#tbody1").append("<tr id='tr" + item.id + "'>" +
                            "<td>" + item.tagName + "</td>" +
                            "<td>" + item.creatorLoginName + "</td>" +
                            "<td>" + item.createTime + "</td>" +
                            "<td>" + item.topicCount + "</td>" +
                            "<td id='td" + item.id + "'>" + state + "</td>" +
                            "<td><div title='" + item.tagName + "' id='" + item.id + "' style='display: flex'>" +
                            "<a onclick='manageTag(this,\"delete\")' style='font-size: 13px;color: red'>" + stateBtn + "</a>" +
                            "</td></div>" +
                            "</tr>")
                    })
                } else {
                    layer.msg(resp.msg);
                }
            }
        });
    }

    //4.管理板块操作
    function manageTag(e, opera) {
        let deleteType = e.text;  //获得操作名以判断是应用还是移除
        let tagName;
        let id;
        let delFlag;
        let confirmMsg;
        if (opera == 'delete') {
            id = $(e).parent().attr('id');
            if (deleteType == '移除') {
                confirmMsg = '确认移除？移除后仍可以重新应用该板块';
                delFlag = '1';
            } else if (deleteType == '应用') {
                confirmMsg = '确认重新应用该板块？';
                delFlag = '0';
            }

        } else if (opera == 'new') {
            tagName = $("#addTag").val();
            if (tagName == '') {
                layer.msg("请输入内容");
                return;
            }
            confirmMsg = '确认新增？';
        }

        layer.confirm(confirmMsg, {
            btn: ['确认', '取消'],
            yes: function () {
                $.get('/adminController/manageTag', {
                    id: id,
                    tagName: tagName,
                    delFlag: delFlag,
                    opera: opera,
                    loginName: getQueryVariable('loginName')
                }, function (resp) {
                    layer.msg(resp.msg);
                    if (opera == 'delete' && resp.code == 0) {
                        let tdState = $("#td" + id);
                        if (tdState.text() == '生效') {
                            tdState.empty();
                            $("#td" + id).text('未生效');
                            $(e).text('应用')
                        } else {
                            tdState.empty();
                            $("#td" + id).text('生效');
                            $(e).text('移除');

                        }
                    } else if (opera == 'new' && resp.code == 0) {   //新增操作直接刷新页面
                        setTimeout(() => run(), 1800);

                        async function run() {
                            await setTimeout;
                            window.location.href = '/admin/index?loginName=' + getQueryVariable("loginName") + '&initNum=4';
                        }
                    }
                });
            }
        })

    }

    //5.修改密码页面
    function loadModifyPwdPage() {
        let appendArea = $("#appendArea");
        appendArea.empty();
        appendArea.append("    <div class='animated fadeIn' style=\"width: 90%;padding-left:40px;padding-top: 25px \">" +
            "                        <div style=\"align-items: center;width: 100%;height: 50px;display: flex;position: relative\">" +
            "                            <div style=\"font-size: 18px;width: 11%\">原密码</div>" +
            "                            <input id=\"oldPwd\" style=\"border-left: none; border-right: none; border-top: none;" +
            "                            border-bottom:1px solid ;width: 70%;font-size: 18px\" type=\"password\">" +
            "                        </div>" +
            "                        <div style=\"align-items: center;width: 100%;height: 50px;display: flex;position: relative\">" +
            "                            <div style=\"font-size: 18px;width: 11%\">新密码</div>" +
            "                            <input id=\"newPwd\" style=\"border-left: none; border-right: none; border-top: none;" +
            "                            border-bottom:1px solid ;width: 70%;font-size: 18px\" type=\"password\">" +
            "                        </div>" +
            "                        <div style=\"align-items: center;width: 100%;height: 50px;display: flex;position: relative\">" +
            "                            <div style=\"font-size: 18px;width: 11%\">密码确认</div>" +
            "                            <input id=\"pwdConfirm\" style=\"border-left: none; border-right: none; border-top: none;" +
            "                            border-bottom:1px solid ;width: 70%;font-size: 18px\" type=\"password\">" +
            "                        </div>" +
            "                       <div style=\"width: 10%;display: flex;position: relative;top: 25px\">  " +
            "                           <button id=\"modifyPwdBtn\" type=\"button\" onclick='modifyPwd()'" +
            "                       style=\"width: 100%;background-color: #000000;color: white;border: #000000;cursor:" +
            "                       pointer;height: 35px;border-radius: 9px\">提交修改</button>" +
            "                       </div>  " +
            "                    </div>");
    }

    //5.修改密码操作
    function modifyPwd() {
        let oldPwd = $("#oldPwd").val();
        let newPwd = $("#newPwd").val().trim();
        let pwdConfirm = $("#pwdConfirm").val().trim();
        if (oldPwd == '' || newPwd == '' || pwdConfirm == '') {
            layer.msg("请完善信息");
        } else if (newPwd != pwdConfirm) {
            layer.msg("新密码两次输入不一致");
        } else {
            $.get("/adminController/modifyPwd", {
                loginName: getQueryVariable("loginName"),
                newPwd: newPwd,
                oldPwd: oldPwd
            }, function (resp) {
                if (resp.code == 0) {
                    layer.msg(resp.msg);
                    setTimeout(() => run(), 1800);

                    async function run() {
                        await setTimeout;
                        window.location.href = '/admin/index?loginName=' + getQueryVariable("loginName") + '&initNum=5';
                    }
                } else {
                    layer.msg(resp.msg);
                }
            }, "json");
        }

    }


</script>
</body>
</html>